// pages/home/marketing/marketing.js
const API = require('../../../../utils/api')
const app = getApp()

Page({

    /**
     * 页面的初始数据
     */
    data: {
        page:'pages/home/marketing/marketing',
        canvasShow: false,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.get_marketingSum_record()
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function(){
        let hasUserInfo = app.globalData.hasUserInfo
        if( !hasUserInfo ){
            wx.reLaunch({
              url: '/pages/login/login?back=/pages/home/marketing/marketing',
            })
        }
        app.creat_records('view') //日志记录
    },

    /**
     * 接口 - 获取记录
     */
    get_marketingSum_record:function(){
        console.log( app.globalData.userInfo )
        let that = this
        API.get_marketingSum_record({
            type: 1,
            userId: app.globalData.userInfo.id,
        }).then( res => {
            if( res.code == 200 ){
                that.setData({
                    record: res.data
                })
            }
        })
    }, 

    /**
     * 获取我的二维码
     */
    creat_wxmini_qrcode:function(){
        this.setData({
            canvasShow: true,
            canvasId: 'shareImg'  //+ Date.parse(new Date())
        })
        console.log('打开组件画图',this.data.canvasId)
    },

    /**
     * 事件 - 联系领奖客服
     */
    contact:function(){
        app.contact()
    },

     /**
      * 路由 - 园区首页
      */
    routePark:function(){
        wx.navigateTo({
          url: '/pages/park/park?id=119',
        })
    },


    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    onShareTimeline: function(){

    },
})